// Copyright 2014 Google Inc. All Rights Reserved

#include <errno.h>
#include <irt_syscalls.h>
#include <poll.h>

int poll(struct pollfd *p, nfds_t cnt, long timeout) {
  ENOSYS_IF_NULL(__nacl_irt_poll)
  int count = 0;

  int result = __nacl_irt_poll(p, cnt, timeout, &count);
  if (result != 0) {
    errno = __nacl_abi_errno_to_errno(result);
    return -1;
  }
  return count;
}
